package com.zf.shuashua.ui.mine.notice;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseViewHolder;
import com.meis.base.mei.adapter.MeiBaseAdapter;
import com.zf.shuashua.R;
import com.zf.shuashua.api.Store;
import com.zf.shuashua.bean.FansList;

import java.util.List;

public class MessageFansListAdapter extends MeiBaseAdapter<FansList.DataBean> {
    private TextView btFans;

    public MessageFansListAdapter(int layoutResId, @Nullable List<FansList.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(final BaseViewHolder helper, final FansList.DataBean item) {
        if (item.getFans() != null) {
            helper.setText(R.id.tvName, item.getFans().getName() + "")
                    .setText(R.id.tvSign, item.getFans().getSignature())
                    .addOnClickListener(R.id.tvIsFocus);
            Glide.with(mContext)
                    .load(item.getFans().getAvatar())
                    .circleCrop()
                    .into((ImageView) helper.getView(R.id.imgAvatar));
            btFans = helper.getView(R.id.tvIsFocus);
            if (Store.getInstance().getuserId().equals(item.getFans().getId() + "")) {
                btFans.setVisibility(View.GONE);
                return;
            }
            if (item.getFollow_status() == 0) {
                btFans.setText("关注");
                btFans.setBackgroundResource(R.drawable.fans_off);
            } else {
                btFans.setText(item.getFollow_status_text());
                btFans.setBackgroundResource(R.drawable.fans_no);
            }
        }
    }
}